﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace T5tk1
{
    public partial class Log : Form
    {
        public Log()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            bool result=false;
            string id = UsName.Text.ToString().Trim();
            string pwd = UsPwd.Text.ToString().Trim();
            if (id == "" || pwd == "")
            {
                MessageBox.Show("用户名或密码不能为空！", "非空提示");
            }
            else
            {
                string sql = string.Format("select * from admin2 where UserName='{0}'and UserPwd='{1}'", id, pwd);
                SqlDataReader reader = DBHelper.GetDataReader(sql);

                while (reader.Read())
                {
                    
                    MessageBox.Show("登录成功！");
                    result = true;
                    break;

                }
                if (result!=true)
                {
                    MessageBox.Show("登录失败");
                }
                reader.Close();

            }
        }

        private void btRegister_Click(object sender, EventArgs e)
        {
            Log form1 = new Log();
            Form2 form2 = new Form2();
            Hide();
            form2.ShowDialog();


        }
    }
}
